package com.zxb.core.common.config;

import java.nio.charset.StandardCharsets;

import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Zxb
 */
@Configuration
public class TomcatConfig {
    @Bean
    public TomcatServletWebServerFactory servletContainer() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.setUriEncoding(StandardCharsets.UTF_8);
        factory.addConnectorCustomizers((connector -> {
            Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
            protocol.setMaxThreads(1500);
            protocol.setMaxConnections(10000);
            protocol.setConnectionTimeout(60000);

        }));
        return factory;
    }
}
